﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="QuestionList.aspx.cs" Inherits="Page_Community_QuestionList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="format-detection" content="telephone=no" />
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <title>咨询</title>
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />

    <script src="../../Scripts/WebForms/Common.js"></script>
    <script src="../../Scripts/jquery-1.8.0.min.js"></script>
    <script src="../../Scripts/slick.min.js"></script>
    <script src="../../Scripts/viewport.js"></script>
    <link href="../../CSS/community-info.css" rel="stylesheet" />
    <link href="../../CSS/slick.css" rel="stylesheet" />
    <link href="../../CSS/base-640.css" rel="stylesheet" />
</head>
<body>
    <div class="container clearfix">
        <div class="content-list">

            <div class="list">
                <!--  用户信息 -->
                <div class="hd clearfix">
                    <img src="http://wx.witontek.com:80/eHospital/page_mobile/assets/images/pic_doctor2@2x.png" />
                    <p class="name">sb</p>
                </div>
                <p class="text">约翰尼德普</p>

            </div>
        </div>

        <div class="comment">
            <ul class="tab clearfix">
                <li><span>咨询</span></li>
            </ul>
            <div class="return-comment">
                <ul id="shareList">
                    <%--<%if (CommunityTopicList != null)
                    {%>
                <ul id="shareList">
                    <%foreach (var item in CommunityTopicList)
                        { %>
                    <li class="clearfix" onclick="window.open('TopicDetial.aspx?topicId=<%=item.Id %>&openid=<%=openid %>','_self')">
                        <img src="<%=item.HeadImg %>">
                        <span class="name"><%=item.Name %></span>
                        <span class="number">(+<%=item.Number %>)</span>
                        <p class="time"><%=item.AddTime %></p>
                        <p class="mes"><%=item.Contents %></p>
                        <%if (!string.IsNullOrEmpty(item.imgs))
                            {%>
                        <ul class="user-pic-list clearfix">
                            <% var imgList = item.imgs.Split(',');
                                foreach (var items in imgList)
                                {%>
                            <li class="ng-scope">
                                <div class="img">
                                    <img src="<%=items %>">
                                </div>
                            </li>
                            <%}%>
                        </ul>
                        <% } %>
                    </li>
                    <% } %>
                </ul>
                <% }
                    else
                    {%>
                <div class="no_record noneData" style="">
                    <div>
                        <img src="http://cdn.xsmore.com/Images/Shop/no-data-icon.png"><br>
                        无咨询记录
                    </div>
                </div>
                <% }%>--%>
                </ul>
            </div>
        </div>

        <div class="no_record noneData" style="display: none;">
            <div>
                <img src="http://cdn.xsmore.com/Images/Shop/no-data-icon.png"><br>
                无咨询记录
            </div>
        </div>
        <div class="loading"style="text-align: center;">
            加载中...
        </div>
        <div class="loadNone" style="text-align: center; display: none">
            <p>已加载完毕</p>
        </div>

        <a href="NewTopic.aspx?openid=<%=openid %>&CardId=<%=DoctorCardId %>" class="link">
            <img src="../../Images/c-write.png" /></a>
    </div>
</body>


<script type="text/javascript">
    var para = {
        PageIndex: 1, PageSize: 3
    }
    var jsonresults = [];

    var isLoaded = false, //所有数据是否已经加载完
    isLoadedOnce = false,//本次数据是否加载完
    bottom = 2; //距底部多少就可以继续加载


    $().ready(function () {

        //重新获取数据
        $("#shareList").html("");
        para.PageIndex = 1;
        isLoaded = false;
        isLoadedOnce = false;
        $(".noneData").hide();
        $(".loadNone").hide();
        GetList(1);

    });
    $(window).on("scroll", function () {
        win = $(window);
        if (isLoadedOnce || isLoaded) return;
        var scrollTop = win.scrollTop(),
            winH = win.height(),
            docHeight = $(document).height();
        if (scrollTop + winH + bottom >= docHeight) {
            para.PageIndex++;
            GetList(para.PageIndex);
        }
    })

    function GetList(pageIndex) {
        isLoadedOnce = true;
        $(".loading").show();
        $.post("/Handler/CommunityHandler.ashx?Action=GetQuestionList", { PageIndex: pageIndex, PageSize: para.PageSize, Openid: '<%=openid%>' }, function (data) {
            if (data == "" || typeof (eval("(" + data + ")")) == "undefined") {
                isLoaded = true;
                //$(".count").text("共有" + 0 + "条数据");
                $(".loading").hide();
                $(".loadNone").hide();
                $(".noneData").hide();
                if (para.PageIndex == 1) {
                    $(".noneData").show();
                }
                else {
                    $(".loadNone").show();
                }
            }
            else {
                //获取JSON数据
                var html = "";
                var imgtemp = "";
                var list = eval("(" + data + ")");
                if (typeof (list) != "undefined" && list.length > 0) {
                    var count = 0;
                    var TotalCount = eval("(" + data + ")").length;
                    var temp = "<li class='clearfix' onclick=window.open('TopicDetial.aspx?topicId={topicID}&openid=<%=openid %>','_self')>"
                                    + '<img src="{headImg}">'
                                    + '<span class="name">{name}</span>'
                                    + '<span class="number">(+{number})</span>'
                                    + '<p class="time">{addtime}</p>'
                                    + '<p class="mes">{contents}</p>'
                                    + '<ul class="user-pic-list clearfix">{imgsList}'
                                    + '</ul>'
                             + '</li>';

                    var img = '<li class="ng-scope">'
                                    + '<div class="img">'
                                        + '<img src="{imgss}">'
                                    + '</div>'
                                + '</li>';

                    for (var i = 0; i < list.length; i++) {
                        if (list[i].imgs != '' && list[i].imgs != null) {
                            var imgs = list[i].imgs.split(',');
                            for (var j = 0; j < imgs.length; j++) {
                                imgtemp += img.replace(/{imgss}/, imgs[j])
                            }
                        }

                        html += temp.replace(/{topicID}/, list[i].Id)
                        .replace(/{headImg}/, list[i].HeadImg)
                        .replace(/{name}/, list[i].Name)
                        .replace(/{number}/, list[i].Number)
                        .replace(/{addtime}/, ChangeNewDateFormat(list[i].AddTime))
                        .replace(/{contents}/, list[i].Contents)
                        .replace(/{imgsList}/, imgtemp);
                        count++;
                        imgtemp = "";
                    }

                    $(html).appendTo($("#shareList"));
                    isLoadedOnce = false;
                    if (count < para.PageSize || para.PageSize * pageIndex == TotalCount) {
                        //isLoaded = true;
                        $(".loading").hide();
                    }
                }
                else {
                    $(".loading").hide();
                    $(".loadNone").show();
                }
            }
        })
    };

</script>

</html>
